home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Freelog 125
/
Freelog_MarsAvril2015_No125.iso
/
Musique
/
Quod Libet
/
quodlibet-3.3.0-portable.exe
/
quodlibet-3.3.0-portable
/
data
/
bin
/
ctypes
/
_endian.pyc
(
.txt
)
< prev
next >
Wrap
Python Compiled Bytecode
|
2014-12-31
|
2KB
|
58 lines
# Source Generated with Decompyle++
# File: in.pyc (Python 2.7)
import sys
from ctypes import *
_array_type = type(Array)
def _other_endian(typ):
"""Return the type with the 'other' byte order. Simple types like
c_int and so on already have __ctype_be__ and __ctype_le__
attributes which contain the types, for more complicated types
arrays and structures are supported.
"""
if hasattr(typ, _OTHER_ENDIAN):
return getattr(typ, _OTHER_ENDIAN)
if None(typ, _array_type):
return _other_endian(typ._type_) * typ._length_
if None(typ, Structure):
return typ
raise None('This type does not support other endian: %s' % typ)
class _swapped_meta(type(Structure)):
def __setattr__(self, attrname, value):
if attrname == '_fields_':
fields = []
for desc in value:
name = desc[0]
typ = desc[1]
rest = desc[2:]
fields.append((name, _other_endian(typ)) + rest)
value = fields
super(_swapped_meta, self).__setattr__(attrname, value)
if sys.byteorder == 'little':
_OTHER_ENDIAN = '__ctype_be__'
LittleEndianStructure = Structure
class BigEndianStructure(Structure):
'''Structure with big endian byte order'''
__metaclass__ = _swapped_meta
_swappedbytes_ = None
elif sys.byteorder == 'big':
_OTHER_ENDIAN = '__ctype_le__'
BigEndianStructure = Structure
class LittleEndianStructure(Structure):
'''Structure with little endian byte order'''
__metaclass__ = _swapped_meta
_swappedbytes_ = None
else:
raise RuntimeError('Invalid byteorder')